home *** CD-ROM | disk | FTP | other *** search
- Path: news.ov.com!news
- From: glenn@ov.com (Fletcher.Glenn@ov.com)
- Newsgroups: comp.lang.c
- Subject: Re: problem w/ realloc
- Date: 22 Mar 1996 22:46:29 GMT
- Organization: OpenVision
- Message-ID: <4ivak5$95t@spanky.pls.ov.com>
- References: <4iqef0$dqq@montana.avicom.net>
- Reply-To: glenn@ov.com
- NNTP-Posting-Host: foghorn.pls.ov.com
-
- In article dqq@montana.avicom.net, zoot@montana.avicom.net (John Greenup) writes:
- >I've been porting a piece of code from AIX 3.2.5 to linux 1.2.8
- >(gcc 2.7.0) recently, and finaly chased down the last :-) bug. The code
- >assumes that if you have a memory block, and you realloc it smaller, it
- >doesn't move the block of memory, it just makes the "usable size" of it
- >smaller. (in fact, my textbook ("advanced programming in the unix
- >environment" stevens) supports this usage) unfortunately, xxgdb has
- >revealed that the realloc is moving my pointer! am I mistaken about the
- >standards, or is this a special case I'm not aware of?
- >any help appreciated-
- >john greenup
- >Zoot Enterprises
- >zoot@www.avicom.net
- >
-
-
- To what standard are you referring? All that realloc promises to do is to
- return a pointer to a memory area of the specified size and to preserve
- existing data (if any). There is nothing in the function description that
- says anything about where this pointer will point to, nor is there any
- guarantee that it will not change from the pointer given to the function.
- You cannot and must not make any assumptions about the values returned
- from allocation routines except for NULL.
-
- Fletcher.Glenn@ov.com
-
-
-